package com.lms.collection;

import java.util.*;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-06-29 07:43
 * @Description:
 */
public class ListIteratorDemo {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9);
        ListIterator<Integer> listIterator = list.listIterator();
//        listIterator.add(11);
        while (listIterator.hasNext()) {
            System.out.print("index:"+listIterator.nextIndex());
            System.out.println(",value:"+listIterator.next());
        }
        System.out.println("==========");
        while (listIterator.hasPrevious()) {
            System.out.print("index:"+listIterator.previousIndex());
            System.out.println(",value:"+listIterator.previous());
        }

    }
}
